﻿
@{
    Layout = null;
}

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>企业登录 -- 企业用户--【赛码网】在线考试首选品牌</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />
    <link rel="shortcut icon" href="~/Common/img/icon.svg" type="image/x-icon" />    
    <link href="~/Common/css/all-exam.css" rel="stylesheet" />

    <link href="~/Common/css/user/login.css" rel="stylesheet" />

    <link href="~/Common/css/comp/comp-enterprise.css" rel="stylesheet" />
</head>
<body>
    <!--head-->
    <div class="head">
        <div class="head-bar public">
            <div class="logo">
                <a href="/"><img src="https://kao.acmcoder.com/images/logo.png" /></a>
                <p><span>企业版</span></p>
            </div>
        </div>
    </div>
    <!--head  end-->
    <div class="main-box">
        <div class="userCnt">
            <div class="loginCnt">
                <h1>登录</h1>
                <div class="login-box">
                    <ul>
                        <li>
                            <input type="text" id="phone" class="login-text input" placeholder="请输入手机号" maxlength="11" />
                        </li>
                        <li>
                            <input type="password" id="pwd" class="login-text input" placeholder="请输入密码" maxlength="20" />
                        </li>
                        <li class="login-error" id="err_msg" style="display: none;"><i></i>手机号或密码输入错误</li>
                        <li>
                            <input type="button" value="登录" id="sbtn" class="login-btn btn" />
                        </li>
                        <li class="login-t">
                            <span>
                                <input type="checkbox" id="auto_login" /> <label for="auto_login">下次自动登录</label>
                            </span>
                            <a href="toFindPwd">忘记密码？</a>
                            <div class="clear"></div>
                        </li>
                    </ul>
                </div>
                <div class="login-f">
                    还没有账号，<a href="regist">马上注册 >></a>
                </div>
            </div>
        </div>
    </div>

    <script src="~/Common/js/jquery.min.js" type="text/javascript" charset="utf-8"></script>
    <script type="text/javascript" src="https://cdn.acmcoder.com/static/1.0.1/js/jquery.cookie.js"></script>
    <script src="~/Common/js/footer-exam.js"></script>

    <script src="~/Common/js/all.js" type="text/javascript" charset="utf-8"></script>
    <script src="~/Common/js/check/dataCkeck.js" type="text/javascript" charset="utf-8"></script>
    <script src="~/Common/js/check/md5.js" charset="utf-8"></script>
    <script type="text/javascript">
        var checkMobile = function (str) {
            var re = /^1\d{10}$/;
            if (re.test(str))
                return true;
            else
                return false;
        }
        var checkPwd = function (str) {
            var re = /^[a-zA-z0-9]\w{5,}$/;
            if (re.test(str))
                return true;
            else
                return false;
        }
        var setErrMsg = function (_id, msg) {
            if (_id.parent().find('span').length == 0)
                _id.parent().addClass('regisit-error').append('<span class="login-error "><i></i>' + msg + '</span>');
        }
        $(function () {
            var $phone = $('#phone'), $pwd = $('#pwd'), $err_msg = $('#err_msg');
            $('#sbtn').click(function () {
                var tosub = true;
                if ($.trim($phone.val()) == '') {
                    tosub = false;
                    setErrMsg($phone, '请输入手机号码');
                } else if (!checkMobile($.trim($phone.val()))) {
                    tosub = false;
                    setErrMsg($phone, '手机号码格式不正确');
                }
                if ($.trim($pwd.val()) == '') {
                    tosub = false;
                    setErrMsg($pwd, '请输入密码');
                } else if (!checkPwd($.trim($pwd.val()))) {
                    tosub = false;
                    setErrMsg($pwd, '密码输入格式错误');
                }
                if (tosub) {
                    $.ajax({
                        url: "http://localhost:23975/api/show?name=" + $phone.val(),
                        type: "get",
                        beforSend:function(XHR){XHR.setRequestHeader('Authorization','BasicAuth @ViewBag.Ticket')},
                        success: function (data, status) {
                            console.log(data);
                            console.log(status);
                            if(data!=null)
                            {
                                if (data.PassWord == $pwd.val())
                                {
                                    location.href = "/Show/show";
                                }
                                //if(data.pwd!=$pwd.val())
                                //{
                                //    alert("密码错误");
                                //}
                            }
                            else
                            {
                                alert("该用户名不存在，请注册!");
                            }
                        }
            })
        }

            });
            $('li input').keydown(function () {
                $err_msg.hide();
                $(this).parent().removeClass('regisit-error');
                $(this).parent('span').removeClass('regisit-error');
                $(this).siblings('span').remove();
            });
            $(document).keydown(function (event) {
                if (event.keyCode == 13)
                    $('#sbtn').click();
            });
        });
    </script>
</body>
</html>
